package com.niit.servlet;

import com.niit.domain.Product;
import com.niit.service.IProductService;
import com.niit.service.impl.ProductServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "ProductServlet", value = "/ProductServlet")
public class ProductServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //书画展示，创建对象
        IProductService ips=new ProductServiceImpl();


        List<Product> productList=ips.productService(5);
        //将list集合存放在session中
        HttpSession proSession=request.getSession();
        proSession.setAttribute("productList",productList);


        List<Product> productList1=ips.Is_goodService(8);
        HttpSession proSession1=request.getSession();
        proSession1.setAttribute("productList1",productList1);


        List<Product> productList2=ips.Is_goodService2(4);
        HttpSession proSession2=request.getSession();
        proSession1.setAttribute("productList2",productList2);
        //重定向
        response.sendRedirect("index.jsp");


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
